let timer = null
// worker线程接收主线程信息
self.onmessage = (e) => {
    const { time } = e.data;
    // 处理数据
    let timeDiff = new Date().getTime() - time // 计算时间差
    if(timer) {
        clearInterval(timer)
        timer = null
    }
    timer = setInterval(() => {
        //  worker线程将结果发送回主线程
        self.postMessage(new Date().getTime() - timeDiff)
    }, 1000)
}